package com.assjirc.commands;

import com.assjirc.annotations.Command;
import com.assjirc.frames.GUI;

@Command("join")
public class Join implements Executable {

	@Override
	public void execute(String params, GUI gui) {
		if (params == null || params.equals("")) {
			gui.getErrorLabel().setText("not enough params");
		} else if (!params.contains(" ")) {
			gui.joinChannel(params, null);
		} else {
			String[] split = params.split(" ");
			if (split.length > 2) {
				gui.getErrorLabel().setText("too many params");
			} else {
				gui.joinChannel(split[0], split[1]);
			}
		}
	}

	@Override
	public String getDetailedHelp(String... params) {
		return getSimpleHelp() + ", syntax: /j <channel> [key]";
	}

	@Override
	public String getSimpleHelp() {
		return "attempts to join a channel";
	}

}
